// swift-tools-version:6.0
import PackageDescription

let package = Package(
    name: "swift-learning",
    products: [
        // chapter_computational_complexity
        .executable(name: "time_complexity", targets: ["time_complexity"]),
        .executable(name: "worst_best_time_complexity", targets: ["worst_best_time_complexity"]),
        .executable(name: "space_complexity", targets: ["space_complexity"]),
        // chapter_array_and_linkedlist
        .executable(name: "array", targets: ["array"]),
        .executable(name: "my_list", targets: ["my_list"]),
        .executable(name: "list", targets: ["list"]),
        .executable(name: "linked_list", targets: ["linked_list"]),

        // chapter_stack_and_queue
        .executable(name: "stack", targets: ["stack"]),
        .executable(name: "linkedlist_stack", targets: ["linkedlist_stack"]),
        .executable(name: "array_stack", targets: ["array_stack"]),
        .executable(name: "queue", targets: ["queue"]),
        .executable(name: "linkedlist_queue", targets: ["linkedlist_queue"]),
        .executable(name: "array_queue", targets: ["array_queue"]),
        .executable(name: "deque", targets: ["deque"]),
        .executable(name: "linkedlist_deque", targets: ["linkedlist_deque"]),
        .executable(name: "array_deque", targets: ["array_deque"]),

        // chapter_tree
        .executable(name: "binary_tree", targets: ["binary_tree"]),
        .executable(name: "binary_tree_bfs", targets: ["binary_tree_bfs"]),
        .executable(name: "binary_tree_dfs", targets: ["binary_tree_dfs"]),
        .executable(name: "binary_search_tree", targets: ["binary_search_tree"]),
        .executable(name: "avl_tree", targets: ["avl_tree"]),

        // swift-log
        .executable(name: "LearnSwiftLog", targets: ["LearnSwiftLog"]),

        // swiftsyntax
        .executable(name: "importformatter", targets: ["importformatter"]),

        // swift-cross-ui
        // .executable(name: "CounterExample", targets: ["CounterExample"])


    ],
    dependencies: [
        .package(url: "https://github.com/apple/swift-log.git", branch: "main"),
        .package(url: "https://github.com/swiftlang/swift-syntax.git", branch: "main"),

        // .package(url: "https://github.com/stackotter/swift-cross-ui", branch: "main")
    ],
    targets: [
        // helper
        .target(name: "utils", path: "utils"),
        // chapter_computational_complexity
        .executableTarget(name: "time_complexity", path: "chapter_computational_complexity", sources: ["time_complexity.swift"]),
        .executableTarget(name: "worst_best_time_complexity", path: "chapter_computational_complexity", sources: ["worst_best_time_complexity.swift"]),
        .executableTarget(name: "space_complexity", dependencies: ["utils"], path: "chapter_computational_complexity", sources: ["space_complexity.swift"]),
        // chapter_array_and_linkedlist
        .executableTarget(name: "array", path: "chapter_array_and_linkedlist", sources: ["array.swift"]),
        .executableTarget(name: "my_list", path: "chapter_array_and_linkedlist", sources: ["my_list.swift"]),
        .executableTarget(name: "list", path: "chapter_array_and_linkedlist", sources: ["list.swift"]),
        .executableTarget(name: "linked_list", dependencies: ["utils"], path: "chapter_array_and_linkedlist", sources: ["linked_list.swift"]),

        // chapter_stack_and_queue
        .executableTarget(name: "stack", path: "chapter_stack_and_queue", sources: ["stack.swift"]),
        .executableTarget(name: "linkedlist_stack", dependencies: ["utils"], path: "chapter_stack_and_queue", sources: ["linkedlist_stack.swift"]),
        .executableTarget(name: "array_stack", path: "chapter_stack_and_queue", sources: ["array_stack.swift"]),
        .executableTarget(name: "queue", path: "chapter_stack_and_queue", sources: ["queue.swift"]),
        .executableTarget(name: "linkedlist_queue", dependencies: ["utils"], path: "chapter_stack_and_queue", sources: ["linkedlist_queue.swift"]),
        .executableTarget(name: "array_queue", path: "chapter_stack_and_queue", sources: ["array_queue.swift"]),
        .executableTarget(name: "deque", path: "chapter_stack_and_queue", sources: ["deque.swift"]),
        .executableTarget(name: "linkedlist_deque", path: "chapter_stack_and_queue", sources: ["linkedlist_deque.swift"]),
        .executableTarget(name: "array_deque", path: "chapter_stack_and_queue", sources: ["array_deque.swift"]),

        // chapter_tree
        .executableTarget(name: "binary_tree", dependencies: ["utils"], path: "chapter_tree", sources: ["binary_tree.swift"]),
        .executableTarget(name: "binary_tree_bfs", dependencies: ["utils"], path: "chapter_tree", sources: ["binary_tree_bfs.swift"]),
        .executableTarget(name: "binary_tree_dfs", dependencies: ["utils"], path: "chapter_tree", sources: ["binary_tree_dfs.swift"]),
        .executableTarget(name: "binary_search_tree", dependencies: ["utils"], path: "chapter_tree", sources: ["binary_search_tree.swift"]),
        .executableTarget(name: "avl_tree", dependencies: ["utils"], path: "chapter_tree", sources: ["avl_tree.swift"]),

        // swift-log
        .executableTarget(
            name: "LearnSwiftLog",
            dependencies: [
                .product(name: "Logging", package: "swift-log")
            ],
            path: "swift-log-example",
            sources: ["LearnSwiftLog.swift"]
        ),
        
        // swift-syntax
        .executableTarget(
            name: "importformatter", 
            dependencies: [
                .product(name: "SwiftSyntax", package: "swift-syntax"),
                .product(name: "SwiftParser", package: "swift-syntax")
            ], 
            path: "swiftsyntax-example", 
            sources: ["importformatter.swift"]),
        
        // swift-cross-ui
        // .executableTarget(
        //     name: "CounterExample",
        //     dependencies: [
        //         .product(name: "SwiftCrossUI", package: "swift-cross-ui"),
        //         .product(name: "GtkBackend", package: "swift-cross-ui")
        //     ],
        //     path: "swift-cross-ui-example",
        //     sources: ["CounterExample.swift"]
        // )
    ]
)